package top.yuhaitao.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableZuulProxy
public class GetWayZuulRegexpApplication {

	public static void main(String[] args) {
		SpringApplication.run(GetWayZuulRegexpApplication.class, args);
	}

	//最后默认做为版本号 用版本号可以直接访问
	// http://localhost:8888/springboot-cloud-provider-user/getUserById?id=1	(原)
	// http://localhost:8888/user/springboot-cloud-provider/getUserById?id=1	(现)
	@Bean
	public PatternServiceRouteMapper serviceRouteMapper() {
		return new PatternServiceRouteMapper("(?<name>^.+)-(?<version>u.+$)", "${version}/${name}");
	}
}
